BellmanFord(graph: list of adjacency lists, src: source vertex) -> list of distances
    // graph: 图的邻接表表示
    // src: 起始顶点

    // 初始化所有顶点的最短距离为无穷大，除了起始顶点的最短距离为0
    for each vertex v in graph:
        minDistance[v] = INT_MAX
        sptSet[v] = false  // sptSet表示顶点v是否已经在最短路径树中
    minDistance[src] = 0

    // 对图中的所有边进行V-1次松弛操作
    for count from 1 to V - 1:
        for each edge (u, v) with weight w in graph:
            if graph[u][v] != 0 and not sptSet[v] and minDistance[u] != INT_MAX:
                if minDistance[u] + graph[u][v] < minDistance[v]:
                    minDistance[v] = minDistance[u] + graph[u][v]

    // 检查图中是否存在负权重环
    for each vertex u in graph:
        for each vertex v in graph:
            if graph[u][v] != 0 and minDistance[u] != INT_MAX:
                if minDistance[u] + graph[u][v] < minDistance[v]:
                    // 如果在V-1次迭代后仍然可以更新最短路径，说明存在负权重环
                    printf("Graph contains a negative weight cycle")
                    return

    // 返回从起始顶点到所有其他顶点的最短距离列表
    return minDistance